package com.zut.hospital.controller.staff;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zut.hospital.service.staff.PatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author hyx
 * @date 2019/7/6 19:56
 * @description TODO
 * @Version
 */
@Controller
@RequestMapping ("/hospital")
public class PatController {
    @Autowired
    PatService patService;


    @ResponseBody
    @RequestMapping(value = "/Pat",produces = "application/json;charset=utf-8",method = RequestMethod.POST)
    public String getAllPat(@RequestBody String data)throws ParseException {
        JSONObject jsonObject=JSON.parseObject(data);
        String patCreatTime1=jsonObject.getString("patCreatTime1");
        String patCreatTime2=jsonObject.getString("patCreatTime2");
        new SimpleDateFormat("yyyy-MM-dd").parse(patCreatTime1);
        return patService.dateUtil(new SimpleDateFormat("yyyy-MM-dd").parse(patCreatTime1),new SimpleDateFormat("yyyy-MM-dd").parse(patCreatTime2));

    }
    @ResponseBody
    @RequestMapping(value = "/Med",produces = "application/json;charset=utf-8",method = RequestMethod.POST)
    public String getAllMed(@RequestBody String data)throws ParseException {
        JSONObject jsonObject=JSON.parseObject(data);
        String time1=jsonObject.getString("time1");
        String time2=jsonObject.getString("time2");
        new SimpleDateFormat("yyyy-MM-dd").parse(time1);
        return patService.date(new SimpleDateFormat("yyyy-MM-dd").parse(time1),new SimpleDateFormat("yyyy-MM-dd").parse(time2));

    }





}
